package com.handtransaction.entity;

import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class Demand {
    private Integer did;
    private String dname;
    private Integer duid;
    //发布时间
    //getGtime()返回String
    private Date dtime;
    private BigDecimal dprice;
    private Integer dnumber;
    private String dcid;       //商品类别
    private String ddetail;

    public Demand(){

    }

    public Demand(Integer did, String dname, Integer duid, Date dtime, BigDecimal dprice, Integer dnumber, String dcid, String ddetail) {
        this.did = did;
        this.dname = dname;
        this.duid = duid;
        this.dtime = dtime;
        this.dprice = dprice;
        this.dnumber = dnumber;
        this.dcid = dcid;
        this.ddetail = ddetail;
    }

    public Integer getDid() {
        return did;
    }

    public void setDid(Integer did) {
        this.did = did;
    }

    public String getDname() {
        return dname;
    }

    public void setDname(String dname) {
        this.dname = dname;
    }

    public Integer getDuid() {
        return duid;
    }

    public void setDuid(Integer duid) {
        this.duid = duid;
    }

    public String getDtime() {
        String value =null;
        //将Date类型的时间转换成指定格式的字符串
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        value = dateFormat.format(this.dtime);
        return value;
    }

    public void setDtime(Date dtime) {
        this.dtime = dtime;
    }

    public void setGtime(String gtime) {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        ParsePosition pos = new ParsePosition(0);//从第一个字符开始解析
        this.dtime = f.parse(gtime,pos);
    }

    public void setGtime(){                      
        Date date=new Date();
        this.dtime=date;
    }

    public BigDecimal getDprice() {
        return dprice;
    }

    public void setDprice(BigDecimal dprice) {
        this.dprice = dprice;
    }

    public Integer getDnumber() {
        return dnumber;
    }

    public void setDnumber(Integer dnumber) {
        this.dnumber = dnumber;
    }

    public String getDcid() {
        return dcid;
    }

    public void setDcid(String dcid) {
        this.dcid = dcid;
    }

    public String getDdetail() {
        return ddetail;
    }

    public void setDdetail(String ddetail) {
        this.ddetail = ddetail;
    }





}
